To write a sound component, you need to define two routines that determine the capabilities of your component or to change those capabilities:
A sound component must implement the SoundComponentGetInfo function. The Sound Manager calls this function to get information about the capabilities of your component.
pascal ComponentResult SoundComponentGetInfo
(ComponentInstance ti,
SoundSource sourceID,
OSType selector, void *infoPtr);
Your SoundComponentGetInfo function returns information about your sound component. The sourceID parameter specifies the sound source to return information about, and the selector parameter specifies the kind of information to be returned. If the information occupies 4 or fewer bytes, it should be returned in the location pointed to by the infoPtr parameter. If the information is larger than 4 bytes, the infoPtr parameter is a pointer to a component information list, a 6-byte structure of type SoundInfoList :
typedef struct {
short count;
Handle handle;
} SoundInfoList, *SoundInfoListPtr;
This structure consists of a count and a handle to a variable-sized array. The count field specifies the number of elements in the array to which handle is a handle. It is your component's responsibility to allocate the block of data referenced by that handle, but it is the caller's responsibility to dispose of that handle once it is finished with it.
The data type of the array elements depends on the kind of information being returned. For example, the selector siSampleSizeAvailable indicates that you should return a list of the sample sizes your component can support. You return the information by passing back, in the infoPtr parameter, a pointer to an integer followed by a handle to an array of integers.
If your component cannot provide the information specified by the selector parameter, it should pass the selector to its source component.
Your SoundComponentGetInfo function is not called at interrupt time if it is passed a selector that might cause it to allocate memory for the handle in the component information list.
Your SoundComponentGetInfo function should return noErr if successful or an appropriate result code otherwise.
See "Finding and Changing Component Capabilities" for a sample SoundComponentGetInfo function.
A sound component must implement the SoundComponentSetInfo function. The Sound Manager calls this function to modify settings of your component.
pascal ComponentResult SoundComponentSetInfo
(ComponentInstance ti,
SoundSource sourceID,
OSType selector, void *infoPtr);
Your SoundComponentSetInfo function is called by the Sound Manager to set one of the settings for your component, as specified by the selector parameter. If the information associated with that selector occupies 4 or fewer bytes, it is passed on the stack, in the infoPtr parameter itself. Otherwise, the infoPtr parameter is a pointer to a structure of type SoundInfoList . See the description of SoundComponentGetInfo for more information about the SoundInfoList structure.
If your component cannot modify the settings specified by the selector parameter, it should pass the selector to its source component.
| Previous | Chapter contents | Chapter top | Section top | Next |